home *** CD-ROM | disk | FTP | other *** search
/ BCI NET / BCI NET Dec 94.iso / archives / programming / source / jade-3.2.lha / jade-3.2 / man / jade.info-10 < prev    next >
Encoding:
GNU Info File  |  1994-10-16  |  35.1 KB  |  965 lines

  1. This is Info file jade.info, produced by Makeinfo-1.55 from the input
  2. file jade.texi.
  3.  
  4. START-INFO-DIR-ENTRY
  5. * Jade: (jade).            An editor for X11 and AmigaDOS
  6. END-INFO-DIR-ENTRY
  7.  
  8.    This is Edition 1.3, last updated 7 October 1994, of `The Jade
  9. Manual', for Jade, Version 3.2.
  10.  
  11.    Jade is a text editor for X11 (on Unix) and the Amiga.
  12.  
  13.    Copyright 1993, 1994 John Harper.
  14.  
  15.    Permission is granted to make and distribute verbatim copies of this
  16. manual provided the copyright notice and this permission notice are
  17. preserved on all copies.
  18.  
  19.    Permission is granted to copy and distribute modified versions of
  20. this manual under the conditions for verbatim copying, provided that
  21. the entire resulting derived work is distributed under the terms of a
  22. permission notice identical to this one.
  23.  
  24. 
  25. File: jade.info,  Node: Process Objects,  Next: Asynchronous Processes,  Up: Processes
  26.  
  27. Process Objects
  28. ---------------
  29.  
  30.    A "process object" is a type of Lisp object used to provide a link
  31. between a `physical' process running in the operating system and Jade's
  32. Lisp system. Each process object consists of a number of components
  33. (references to other Lisp objects); these components are used when the
  34. object is used to run a subprocess.
  35.  
  36.    Process objects which aren't currently being used to run a subprocess
  37. store the exit value of the last subprocess which was run on that
  38. object.
  39.  
  40.  - Function: processp OBJECT
  41.      This function returns `t' when its argument is a process object.
  42.  
  43.    The programmer-accessible components of a process object are,
  44.  
  45. "Output stream"
  46.      A normal Lisp output stream (*note Output Streams::.), all data
  47.      which the subprocess outputs to its `stdout' channel is copied to
  48.      this output stream. *Note Process I/O::.
  49.  
  50. "State change function"
  51.      A Lisp function, called each time the state of the subprocess
  52.      being run on the object changes. *Note Process States::.
  53.  
  54. "Program name"
  55.      The name of the program (a string) to execute when the subprocess
  56.      is created.
  57.  
  58. "Program arguments"
  59.      A list of strings defining the arguments which the program executed
  60.      is given.
  61.  
  62. "Directory"
  63.      When a subprocess is started its current working directory is set
  64.      to the directory named by this component of its process object.
  65.  
  66. "Connection type"
  67.      Asynchronous subprocesses (*note Asynchronous Processes::.) use
  68.      this component to decide how to connect to the I/O channels of the
  69.      subprocess.  Current options include pseudo-terminals and pipes.
  70.  
  71.  - Function: make-process &optional OUTPUT-STREAM STATE-FUNCTION
  72.           DIRECTORY PROGRAM ARGS
  73.      This functions creates and returns a new process object. *No
  74.      subprocess will be started.*
  75.  
  76.      The optional arguments are used to define the values of the
  77.      components of the new process object, any undefined components
  78.      will be set to default or null values.
  79.  
  80.    For each component of a process object two functions exist; one to
  81. read the component's value in a specific process object, the other to
  82. set the component's value.
  83.  
  84.  - Function: process-prog PROCESS
  85.      Returns the value of the program name component of the process
  86.      object PROCESS.
  87.  
  88.  - Function: set-process-prog PROCESS PROG-NAME
  89.      Sets the value of the program name component of the process object
  90.      PROCESS to the string PROG-NAME, then returns PROG-NAME.
  91.  
  92.  - Function: process-args PROCESS
  93.      Returns the value of the program arguments component of the
  94.      process object PROCESS.
  95.  
  96.  - Function: set-process-args PROCESS ARG-LIST
  97.      Sets the value of the program arguments component of the process
  98.      object PROCESS to the list ARG-LIST, then returns ARG-LIST.
  99.  
  100.  - Function: process-dir PROCESS
  101.      Returns the value of the directory component of the process object
  102.      PROCESS.
  103.  
  104.  - Function: set-process-directory PROCESS DIRECTORY
  105.      Sets the value of the directory component of the process object
  106.      PROCESS to the string DIRECTORY, then returns DIRECTORY.
  107.  
  108. 
  109. File: jade.info,  Node: Asynchronous Processes,  Next: Synchronous Processes,  Prev: Process Objects,  Up: Processes
  110.  
  111. Asynchronous Processes
  112. ----------------------
  113.  
  114.    An "asynchronous process" is one that runs in parallel with the
  115. editor, basically this means that once the subprocess has been started
  116. (by the `start-process' function) Jade will carry on as normal.
  117.  
  118.    The event loop checks for output from asynchronous processes, any
  119. found is copied to the process' output stream, and calls the the
  120. process' state change function when necessary (*note Process States::.).
  121.  
  122.    When using asynchronous processes you have a choice as to the Unix
  123. mechanism used to connect the `stdin', `stdout' and `stderr' streams of
  124. the subprocess to Jade's process (note that whatever the choice
  125. `stdout' and `stderr' always go to the same place).
  126.  
  127.    The two options currently available are pipes or pseudo-terminals; in
  128. general pseudo-terminals should only be used to provide a direct
  129. interface between the user and a process (i.e. the `*shell*' buffer)
  130. since they allow job control to work properly. At other times pipes
  131. will be more efficient and are used by default.
  132.  
  133.  - Function: start-process &optional PROCESS-OBJECT PROGRAM &rest ARGS
  134.      This function starts an asynchronous subprocess running on the
  135.      process object PROCESS-OBJECT. If PROCESS-OBJECT is undefined a
  136.      new process object is created (by calling the function
  137.      `make-process' with all arguments undefined).
  138.  
  139.      The function always returns the process object which the subprocess
  140.      has been started on. If for some reason the subprocess can't be
  141.      created an error of type `process-error' is signalled.
  142.  
  143.      The optional argument PROGRAM is a string defining the name of the
  144.      program to execute, it will be searched for in all the directories
  145.      in the `PATH' environment variable. The ARGS are strings to pass
  146.      to the subprocess as its arguments.
  147.  
  148.      When defined, the optional arguments overrule the values of the
  149.      related components of the process object.
  150.  
  151.      The following example runs the `ls' program asynchronously, its
  152.      output is inserted into the current buffer.
  153.  
  154.           (let
  155.               ((process (make-process (current-buffer))))
  156.             (start-process process "ls" "-s"))
  157.  
  158.    Note that when Jade terminates it kills all of its asynchronous
  159. subprocesses which are still running without warning.
  160.  
  161.  - Function: process-connection-type PROCESS
  162.      Returns the value of the connection type component of the process
  163.      object PROCESS. See the documentation of the
  164.      `set-process-connection-type' function for the values this may
  165.      take.
  166.  
  167.  - Function: set-process-connection-type PROCESS SYMBOL
  168.      Sets the value of the connection type component of the process
  169.      object PROCESS to SYMBOL, then returns SYMBOL.
  170.  
  171.      SYMBOL should be one of the following symbols,
  172.  
  173.     `pty'
  174.           Use pseudo-terminals to connect to subprocesses running
  175.           asynchronously on this process object.
  176.  
  177.     `pipe'
  178.           Use standard Unix pipes to connect, this is the default value
  179.           of this component.
  180.  
  181. 
  182. File: jade.info,  Node: Synchronous Processes,  Next: Process I/O,  Prev: Asynchronous Processes,  Up: Processes
  183.  
  184. Synchronous Processes
  185. ---------------------
  186.  
  187.    When a "synchronous process" is started Jade waits for it to
  188. terminated before continuing; they are usually used when a Lisp program
  189. must invoke an external program as part of its function, i.e. the
  190. auto-compression feature runs the compression program `gzip'
  191. synchronously when it needs to compress a buffer.
  192.  
  193.    Unlike asynchronous processes their is no choice between pipes and
  194. pseudo-terminals for connecting to a subprocess. Instead, it is possible
  195. to link the `stdin' channel of a synchronous process to a named file.
  196.  
  197.  - Function: run-process &optional PROCESS-OBJECT INPUT-FILE-NAME
  198.           PROGRAM &rest ARGS
  199.      This function starts a process running on the process object
  200.      PROCESS-OBJECT. If PROCESS-OBJECT is undefined a new process object
  201.      is created by calling the `make-process' function.
  202.  
  203.      If defined, the string INPUT-FILE-NAME names the file to connect to
  204.      the standard input of the subprocess, otherwise the subprocess'
  205.      input comes from the null device (`/dev/null').
  206.  
  207.      The optional arguments PROGRAM and ARGS define the name of the
  208.      program to invoke and any arguments to pass to it. The program
  209.      will be searched for in all directories listed in the `PATH'
  210.      environment variable.
  211.  
  212.      If any of the optional parameters are unspecified they should have
  213.      been set in the PROCESS-OBJECT prior to calling this function.
  214.  
  215.      After successfully creating the new subprocess, this function
  216.      simply copies any output from the process to the output stream
  217.      defined by the output stream component of the process object. When
  218.      the subprocess exits its exit-value is returned (an integer). Note
  219.      that the exit-value is the value returned by the
  220.      `process-exit-value' function, see *Note Process Information::.
  221.  
  222.      If, for some reason, the new subprocess can't be created an error
  223.      of type `process-error' is signalled.
  224.  
  225.    The following function definition is taken from the `gzip.jl' file,
  226. it shows how the `run-process' function can be used to uncompress a
  227. file into a buffer.
  228.  
  229.      ;; Uncompress FILE-NAME into the current buffer
  230.      (defun gzip-uncompress (file-name)
  231.        (let
  232.            ((proc (make-process (current-buffer))))
  233.          (message (concat "Uncompressing `" file-name "'") t)
  234.          ;; gunzip can do .Z files as well
  235.          (unless (zerop (run-process proc nil "gunzip" "-c" file-name))
  236.            (signal 'file-error (list "Can't gunzip file" file-name)))))
  237.  
  238. 
  239. File: jade.info,  Node: Process I/O,  Next: Process States,  Prev: Synchronous Processes,  Up: Processes
  240.  
  241. Process I/O
  242. -----------
  243.  
  244.    It is only possible for lisp programs to explicitly send input data
  245. to *asynchronous* processes (by the time it's possible to call a
  246. function to send data to a synchronous process, the process will
  247. already have terminated!). Simply use the process object which an
  248. asynchronous process is running on as a normal Lisp input stream, any
  249. strings or characters written to the stream will immediately be copied
  250. to the `stdin' channel of the subprocess.
  251.  
  252.    With synchronous processes, the only control over input data
  253. possible is by giving the `run-process' function the name of a file
  254. containing the subprocess' input data.
  255.  
  256.    Output data from subprocesses is handled the same way by both
  257. asynchronous and synchronous processes: it is simply copied to the
  258. stream defined by the output stream component of the subprocess'
  259. process object.
  260.  
  261.  - Function: process-output-stream PROCESS
  262.      Returns the value of the output stream component of the process
  263.      object PROCESS.
  264.  
  265.  - Function: set-process-output-stream PROCESS STREAM
  266.      Sets the value of the output stream component of the process object
  267.      PROCESS to the stream STREAM, then returns STREAM.
  268.  
  269.    *Note Streams::.
  270.  
  271. 
  272. File: jade.info,  Node: Process States,  Next: Signalling Processes,  Prev: Process I/O,  Up: Processes
  273.  
  274. Process States
  275. --------------
  276.  
  277.    Each process object has a "state" associated with it; this depends on
  278. the status of the subprocess currently running on the process object (or
  279. not as the case may be).
  280.  
  281.    The possible states are,
  282.  
  283. "running"
  284.      This state means that the subprocess using this process object is
  285.      currently running, i.e. it hasn't been stopped.
  286.  
  287. "stopped"
  288.      Means that the subprocess has been temporarily suspended from
  289.      running.
  290.  
  291. "unused"
  292.      This means that the process object is free to have a new
  293.      subprocess created on it.
  294.  
  295.    Predicates exist which test whether a given process object is in one
  296. of these states.
  297.  
  298.  - Function: process-running-p PROCESS-OBJECT
  299.      Returns `t' when PROCESS-OBJECT is in the running state.
  300.  
  301.  - Function: process-stopped-p PROCESS-OBJECT
  302.      Returns `t' when PROCESS-OBJECT is in the stopped state.
  303.  
  304.  - Function: process-in-use-p PROCESS-OBJECT
  305.      Returns `t' when PROCESS-OBJECT is *not* in the unused state.
  306.  
  307.    The following two functions are used to stop and then subsequently
  308. continue a process running.
  309.  
  310.  - Function: stop-process PROCESS-OBJECT &optional WHOLE-GROUP
  311.      This function suspends execution of the subprocess running on the
  312.      process object PROCESS-OBJECT.
  313.  
  314.      If WHOLE-GROUP is non-`nil' all subprocesses in the process group
  315.      of PROCESS-OBJECT are stopped.
  316.  
  317.  - Function: continue-process PROCESS-OBJECT &optional WHOLE-GROUP
  318.      Use this function to continue a subprocess executing after it has
  319.      been stopped (by the `stop-process' function).
  320.  
  321.      If WHOLE-GROUP is non-`nil' all subprocesses in the process group
  322.      of PROCESS-OBJECT are continued.
  323.  
  324.    The state change function component of a process object defines a
  325. function which will be called each time the state of the process object
  326. changes. If your program needs to be informed when an asynchronous
  327. process terminates this function is the way to do it.
  328.  
  329.  - Function: process-function PROCESS
  330.      Returns the value of the state change function component of the
  331.      process object PROCESS.
  332.  
  333.  - Function: set-process-function PROCESS FUNCTION
  334.      Sets the value of the state change function component of the
  335.      process object PROCESS to the function FUNCTION, then returns
  336.      FUNCTION.
  337.  
  338. 
  339. File: jade.info,  Node: Signalling Processes,  Next: Process Information,  Prev: Process States,  Up: Processes
  340.  
  341. Signalling Processes
  342. --------------------
  343.  
  344.  - Function: signal-process PROCESS-OBJECT SIGNAL-NUMBER &optional
  345.           WHOLE-GROUP
  346.      If the process object PROCESS-OBJECT is being used to run an
  347.      asynchronous subprocess send the signal numbered SIGNAL-NUMBER to
  348.      it.
  349.  
  350.      When the optional argument WHOLE-GROUP is non-`nil' the signal is
  351.      also sent to all processes in the process group of the subprocess.
  352.  
  353.    The following functions use the `signal-process' function to send
  354. some common signals to processes.
  355.  
  356.  - Function: interrupt-process PROCESS-OBJECT &optional WHOLE-GROUP
  357.      Sends the `SIGINT' signal to PROCESS-OBJECT.
  358.  
  359.           (interrupt-process PROCESS-OBJECT WHOLE-GROUP)
  360.           ==
  361.           (signal-process PROCESS-OBJECT `SIGINT' WHOLE-GROUP)
  362.  
  363.  - Function: kill-process PROCESS-OBJECT &optional WHOLE-GROUP
  364.      Sends the `SIGKILL' signal to the PROCESS-OBJECT.
  365.  
  366.           (kill-process PROCESS-OBJECT WHOLE-GROUP)
  367.           ==
  368.           (signal-process PROCESS-OBJECT `SIGKILL' WHOLE-GROUP)
  369.  
  370.    Note that the functions `stop-process' and `continue-process' also
  371. send signals to the subprocess.
  372.  
  373. 
  374. File: jade.info,  Node: Process Information,  Next: Interactive Processes,  Prev: Signalling Processes,  Up: Processes
  375.  
  376. Process Information
  377. -------------------
  378.  
  379.  - Function: process-id PROCESS-OBJECT
  380.      This function returns the operating-system identifier associated
  381.      with the subprocess currently running on the process object
  382.      PROCESS-OBJECT.
  383.  
  384.  - Function: process-exit-value PROCESS-OBJECT
  385.      Returns the integer representing the return code of the last
  386.      subprocess to be run on PROCESS-OBJECT.
  387.  
  388.      If no subprocess has been run on PROCESS-OBJECT, PROCESS-OBJECT is
  389.      currently in the running state or the last subprocess exited
  390.      abnormally (i.e. from a terminal signal) `nil' is returned.
  391.  
  392.  - Function: process-exit-status PROCESS-OBJECT
  393.      This function returns the integer that was the exit status of the
  394.      last subprocess which was run on the process object PROCESS-OBJECT.
  395.  
  396.      Note that the exit status is *not* the value given to the `exit'
  397.      function in a C program, use the `process-exit-value' to access
  398.      this value.
  399.  
  400.      If no process has been run on PROCESS-OBJECT, or the process is
  401.      currently in the running state `nil' is returned.
  402.  
  403. 
  404. File: jade.info,  Node: Interactive Processes,  Prev: Process Information,  Up: Processes
  405.  
  406. Interactive Processes
  407. ---------------------
  408.  
  409.    The Shell mode is usually used to run a shell process in a buffer
  410. (with the `shell' command, *note Shell::.) but in actual fact it is
  411. capable of running (nearly) any type of interactive process. For
  412. example the gdb interface (*note Debugging Programs::.) uses the Shell
  413. mode to handle its user interaction.
  414.  
  415.    The following buffer-local variables control the Shell mode.
  416.  
  417.  - Variable: shell-program
  418.      This variable defines the name of the program to execute. By
  419.      default it is the user's shell.
  420.  
  421.  - Variable: shell-program-args
  422.      A list of arguments which should be given to the process when it is
  423.      started.
  424.  
  425.  - Variable: shell-prompt-regexp
  426.      This regular expression must match the prompt that the process
  427.      emits each time it waits for input. Its standard value of
  428.      `^[^]#$%>)]*[]#$%>)] *' will need to be tailored to the program
  429.      that you are executing.
  430.  
  431.  - Variable: shell-callback-function
  432.      Every time the state of the subprocess changes (*note Process
  433.      States::.) this function is called in the context of the process'
  434.      buffer.
  435.  
  436.  - Variable: shell-output-stream
  437.      All output from the subprocess is copied to this output stream. If
  438.      it is `nil' all output goes to the end of the process' buffer.
  439.  
  440.      Note that this variable is only referenced when the process is
  441.      started.
  442.  
  443.    To use the Shell mode to create an interface with a program simply
  444. use the following steps.
  445.  
  446.   1. Select the buffer which you want to run the subprocess in. The
  447.      value of the `buffer-file-name' attribute of the buffer defines the
  448.      working directory of the subprocess.
  449.  
  450.   2. Set the variables described above to suitable values.
  451.  
  452.   3. Call the `shell-mode' function.
  453.  
  454.   4. Reset the values of the `mode-name' and `major-mode' if necessary
  455.      and install your own keymaps.
  456.  
  457.      Remember that commands essential to the Shell mode (and hence your
  458.      program) are contained in the two keymaps `shell-keymap' and
  459.      `shell-ctrl-c-keymap'. If you need to bind your own commands to
  460.      either of these prefixes make copies of these keymaps (using the
  461.      function `copy-sequence') and bind to the copies.
  462.  
  463.      For example the gdb interface installs its own key bindings from
  464.      the `Ctrl-c' prefix by doing the following in its initialisation.
  465.  
  466.           (defvar gdb-ctrl-c-keymap (copy-sequence shell-ctrl-c-keymap))
  467.           (bind-keys gdb-ctrl-c-keymap
  468.            ;; Gdb mode `Ctrl-c' prefix bindings follow
  469.            ...
  470.  
  471.  - Function: shell-mode
  472.      This function installs the Shell mode and starts a subprocess
  473.      running in the current buffer.
  474.  
  475.      The variables `shell-program', `shell-program-args',
  476.      `shell-prompt-regexp', `shell-callback-function' and
  477.      `shell-output-stream' control the program executed and how it will
  478.      execute.
  479.  
  480.      The process object created is stored in the buffer-local variable
  481.      `shell-process'.
  482.  
  483.  - Variable: shell-process
  484.      This buffer-local variable contains the process object which the
  485.      Shell mode started running in this buffer. If it is `nil' no such
  486.      process exists.
  487.  
  488.  - Variable: shell-keymap
  489.      The root keymap of the Shell mode.
  490.  
  491.  - Variable: shell-ctrl-c-keymap
  492.      The keymap containing the key bindings of the commands in Shell
  493.      mode with a prefix of `Ctrl-c'.
  494.  
  495.    See the Lisp program `gdb.jl' for an example of how to use the Shell
  496. mode as the user interface with an external program.
  497.  
  498. 
  499. File: jade.info,  Node: Miscellaneous Functions,  Next: Debugging,  Prev: Processes,  Up: Programming Jade
  500.  
  501. Miscellaneous Functions
  502. =======================
  503.  
  504.    This section of the manual documents functions and features which
  505. don't comfortably fit elsewhere in this manual.
  506.  
  507. * Menu:
  508.  
  509. * System Information::          Getting details about the host
  510. * User Information::            The name of the user
  511. * Environment Variables::       Reading and writing the environment
  512. * System Time::                 Getting the current time
  513. * Revision Information::        How to check Jade's revision numbers
  514.  
  515. 
  516. File: jade.info,  Node: System Information,  Next: User Information,  Up: Miscellaneous Functions
  517.  
  518. System Information
  519. ------------------
  520.  
  521.  - Function: x11-p
  522.      This function returns `t' when Jade is running on the X11 window
  523.      system.
  524.  
  525.  - Function: unix-p
  526.      This function returns `t' when Jade is running on a variant of the
  527.      Unix operating system.
  528.  
  529.  - Function: amiga-p
  530.      This function returns `t' when Jade is running on an Amiga.
  531.  
  532.  - Function: system-name
  533.      This function returns a string naming the host that Jade is
  534.      running on. When possible this will include the name of the domain
  535.      as well.
  536.  
  537.      In the Amiga version of Jade the environment variable `HOSTNAME' is
  538.      assumed to contain the host's name.
  539.  
  540. 
  541. File: jade.info,  Node: User Information,  Next: Environment Variables,  Prev: System Information,  Up: Miscellaneous Functions
  542.  
  543. User Information
  544. ----------------
  545.  
  546.  - Function: user-login-name
  547.      This function returns a string containing the login name of the
  548.      user.
  549.  
  550.      In the Amiga version this is taken from the environment variable
  551.      `USERNAME'.
  552.  
  553.           (user-login-name)
  554.               => "jsh"
  555.  
  556.  - Function: user-real-name
  557.      This function returns a string containing the `real' name of the
  558.      user; the format of the string will depend on the host system.
  559.  
  560.      In the Amiga version this is taken from the `REALNAME' environment
  561.      variable.
  562.  
  563.           (user-real-name)
  564.               => "John Harper"
  565.  
  566.  - Function: user-home-directory
  567.      This function returns the name of the user's home directory
  568.      terminated by a slash character (`/').
  569.  
  570.      The first place this is looked for is in the `HOME' environment
  571.      variable; if this variable doesn't exist we either use the `SYS:'
  572.      logical device in AmigaDOS or consult the passwd file when in Unix.
  573.  
  574.           (user-home-directory)
  575.               => "/home/jsh/"
  576.  
  577. 
  578. File: jade.info,  Node: Environment Variables,  Next: System Time,  Prev: User Information,  Up: Miscellaneous Functions
  579.  
  580. Environment Variables
  581. ---------------------
  582.  
  583.  - Function: getenv VARIABLE-NAME
  584.      This function returns the value (a string) of the environment
  585.      variable called VARIABLE-NAME. If the specified variable doesn't
  586.      exist `nil' is returned.
  587.  
  588.           (getenv "OSTYPE")
  589.               => "Linux"
  590.  
  591.  - Function: setenv VARIABLE-NAME NEW-VALUE
  592.      This function sets the value of the environment variable called
  593.      VARIABLE-NAME to NEW-VALUE. NEW-VALUE can either be a string
  594.      containing the new contents of the variable or `nil', in which
  595.      case the environment variable is deleted.
  596.  
  597. 
  598. File: jade.info,  Node: System Time,  Next: Revision Information,  Prev: Environment Variables,  Up: Miscellaneous Functions
  599.  
  600. System Time
  601. -----------
  602.  
  603.    No matter what operating system Jade is running on it always an
  604. integer to store a time value. Generally this will be the number of
  605. seconds since some previous date.
  606.  
  607.    The only thing a Lisp program is allowed to assume about a time
  608. value is that as time passes the time value *increases*. This means
  609. that it's possible to compare two time values and know which is the
  610. newer.
  611.  
  612.  - Function: current-time
  613.      Returns an integer denoting the current time.
  614.  
  615.           (current-time)
  616.               => 780935736
  617.  
  618.  - Function: current-time-string
  619.      This function returns a string stating the current time and date
  620.      in a fixed format. An example of the format is,
  621.  
  622.           Fri Sep 30 15:20:56 1994
  623.  
  624.      Each field will always be in the same place, for example,
  625.  
  626.           Thu Sep  1 12:13:14 1994
  627.  
  628.           (current-time-string)
  629.               => "Fri Sep 30 15:20:56 1994"
  630.  
  631. 
  632. File: jade.info,  Node: Revision Information,  Prev: System Time,  Up: Miscellaneous Functions
  633.  
  634. Revision Information
  635. --------------------
  636.  
  637.  - Function: major-version-number
  638.      This function returns a number defining the major version of the
  639.      editor.
  640.  
  641.           (major-version-number)
  642.               => 3
  643.  
  644.  - Function: minor-version-number
  645.      Returns a number defining the minor version of the editor.
  646.  
  647.           (minor-version-number)
  648.               => 2
  649.  
  650. 
  651. File: jade.info,  Node: Debugging,  Next: Tips,  Prev: Miscellaneous Functions,  Up: Programming Jade
  652.  
  653. Debugging
  654. =========
  655.  
  656.    When you have written a Lisp program you will have to debug it
  657. (unless all your programs work first time?). There are two main classes
  658. of errors; syntax errors and semantic errors.
  659.  
  660.    Syntax errors occur when the text you've typed out to represent your
  661. program is not a valid representation of a Lisp object (since a program
  662. is simply an ordered set of Lisp objects). When you try to load your
  663. program the Lisp reader will find the syntax error and tell you about,
  664. unfortunately though it probably won't be able to tell you exactly
  665. where the error is.
  666.  
  667.    The most common source of syntax errors is too few or too many
  668. parentheses; the `Ctrl-Meta-f' and `Ctrl-Meta-b' commands can be used
  669. to show the structure of the program as the Lisp reader sees it.
  670.  
  671.    Semantic errors are what we normally call bugs -- errors in logic,
  672. the program is syntactically correct but doesn't do what you want it
  673. to. For these types of errors Jade provides a simple debugger which
  674. allows you to single step through the Lisp forms of your program as
  675. they are being evaluated.
  676.  
  677.    There are several ways to enter the Lisp debugger; functions can be
  678. marked so that they cause the debugger to be entered when they are
  679. called, breakpoints can be written in functions or it can be called
  680. explicitly with a form to step through.
  681.  
  682.  - Command: trace SYMBOL
  683.      This command marks the symbol SYMBOL so that each time the function
  684.      stored in the function cell of SYMBOL is called the debugger is
  685.      entered immediately.
  686.  
  687.      When called interactively SYMBOL is prompted for.
  688.  
  689.  - Command: untrace SYMBOL
  690.      The opposite of `trace' -- unmarks the symbol.
  691.  
  692.  - Function: break
  693.      This function causes the debugger to be entered immediately. By
  694.      putting the form `(break)' at suitable points in your program
  695.      simple breakpoints can be created.
  696.  
  697.  - Command: step FORM
  698.      This function invokes the debugger to step through the form FORM.
  699.  
  700.      When called interactively FORM is prompted for.
  701.  
  702.    Whenever the Lisp debugger is entered the form waiting to be
  703. evaluated is printed at the bottom of the buffer, at this point the
  704. special debugger commands available are,
  705.  
  706. `Ctrl-c Ctrl-s'
  707.      Step into the current form; this means that in a list form the
  708.      debugger is used to evaluated each argument in turn.
  709.  
  710. `Ctrl-c Ctrl-i'
  711.      Ignore the current form; makes the current form immediately return
  712.      `nil'.
  713.  
  714. `Ctrl-c Ctrl-n'
  715.      Continue evaluating forms normally until the next form at the
  716.      current level is entered, then re-enter the debugger.
  717.  
  718. `Ctrl-c Ctrl-r'
  719.      Continue execution normally. Note that this command is the one to
  720.      use when an error has been trapped.
  721.  
  722. `Ctrl-c Ctrl-b'
  723.      Print a backtrace of the current Lisp call stack, note that calls
  724.      of primitive functions aren't currently recorded in this stack.
  725.  
  726. `Ctrl-c Ctrl-x'
  727.      Prompt for a Lisp form, evaluate it and return this value as the
  728.      result of the current form.
  729.  
  730.    After the form has been evaluated (i.e. after you've typed one of the
  731. commands above) the value of the form is printed in the buffer,
  732. prefixed by the string `=> '.
  733.  
  734.    Note that it is also possible to make certain types of errors invoke
  735. the debugger immediately they are signalled, see *Note Errors::.
  736.  
  737. 
  738. File: jade.info,  Node: Tips,  Prev: Debugging,  Up: Programming Jade
  739.  
  740. Tips
  741. ====
  742.  
  743.    This section of the manual gives advice about programming in Jade.
  744.  
  745.    Obviously there is no *need* to religiously follow every single one,
  746. but following these tips will make your programs easier to read and
  747. (hopefully) more efficient overall.
  748.  
  749.    For advice on getting the most out of the compiler, see *Note
  750. Compilation Tips::.
  751.  
  752. * Menu:
  753.  
  754. * Comment Styles::              Differrent types of comments
  755. * Program Layout::              How I lay out the programs I write
  756. * General Tips::                Do's and Don't's of Jade programming
  757.  
  758. 
  759. File: jade.info,  Node: Comment Styles,  Next: Program Layout,  Up: Tips
  760.  
  761. Comment Styles
  762. --------------
  763.  
  764.    As already described, single-line comments in Lisp are introduced by
  765. a semi-colon (`;') character. By convention a different number of
  766. semi-colons is used to introduce different types of comments,
  767.  
  768. `;'
  769.      A comment referring to the line of Lisp code that it occurs on,
  770.      comments of this type are usually indented to the same depth, on
  771.      the right of the Lisp code. When editing in Lisp mode the command
  772.      `Meta-;' can be used to insert a comment of this type.
  773.  
  774.      For example,
  775.  
  776.           (defconst op-call 0x08)            ;call (stk[n] stk[n-1] ... stk[0])
  777.                                           ; pops n values, replacing the
  778.                                           ; function with the result.
  779.           (defconst op-push 0x10)            ;pushes constant # n
  780.  
  781. `;;'
  782.      Comments starting with two semi-colons are written on a line of
  783.      their own and indented to the same depth as the next line of Lisp
  784.      code. They describe the following lines of code.
  785.  
  786.      For example,
  787.  
  788.           ;; Be sure to remove any partially written dst-file.
  789.           (let
  790.               ((fname (concat file-name ?c)))
  791.             (when (file-exists-p fname)
  792.               (delete-file fname)))
  793.  
  794.      Comments of this type are also placed before a function definition
  795.      to describe the function. This saves wasting memory with a
  796.      documentation string in a module's internal functions.
  797.  
  798.      For example,
  799.  
  800.           ;; Compile a form which occurred at the `top-level' into a
  801.           ;; byte code form.
  802.           ;; defuns, defmacros, defvars, etc... are treated specially.
  803.           ;; require forms are evaluated before being output uncompiled;
  804.           ;; this is so any macros are brought in before they're used.
  805.           (defun comp-compile-top-form (form)
  806.             ...
  807.  
  808. `;;;'
  809.      This type of comment always starts in the first column of the
  810.      line, they are used to make general comments about a program and
  811.      don't refer to any function or piece of code in particular.
  812.  
  813.      For example,
  814.  
  815.           ;;; Notes:
  816.           ;;;
  817.           ;;; Instruction Encoding
  818.           ;;; ====================
  819.           ;;; Instructions which get an argument (with opcodes of zero up to
  820.           ...
  821.  
  822. `;;;;'
  823.      Each program should have a comment of this type as its first line,
  824.      the body of the comment is the name of the file, two dashes and a
  825.      brief description of what the program does. They always start in
  826.      the first column.
  827.  
  828.      For example,
  829.  
  830.           ;;;; compiler.jl -- Simple compiler for Lisp files/forms
  831.  
  832.    If you adhere to these standards the indentation functions provide by
  833. the Lisp mode will indent your comments to the correct depth.
  834.  
  835. 
  836. File: jade.info,  Node: Program Layout,  Next: General Tips,  Prev: Comment Styles,  Up: Tips
  837.  
  838. Program Layout
  839. --------------
  840.  
  841.    The layout that I have used for all the Lisp programs included with
  842. Jade is as follows, obviously this isn't ideal but it seems ok.
  843.  
  844.   1. The first line of the file is the header comment, including the
  845.      name of the file and its general function.
  846.  
  847.   2. Copyright banner.
  848.  
  849.   3. Any `require' forms needed followed by a `provide' form for this
  850.      module. The `require' forms should be before the `provide' in case
  851.      the required modules aren't available.
  852.  
  853.   4. Variable and constant definitions. As a variable is defined any
  854.      initialisation it needs is done immediately afterwards. For example
  855.      a keymap is defined with `defvar' then initialised with the
  856.      `bind-keys' function.
  857.  
  858.      For example,
  859.  
  860.           (defvar debug-buffer (make-buffer "*debugger*")
  861.             "Buffer to use for the Lisp debugger.")
  862.           (set-buffer-special debug-buffer t)
  863.           (add-buffer debug-buffer)
  864.           
  865.           (defvar debug-ctrl-c-keymap (make-keylist)
  866.             "Keymap for debugger's ctrl-c prefix.")
  867.           (bind-keys debug-ctrl-c-keymap
  868.             "Ctrl-s" 'debug-step
  869.             ...
  870.  
  871.   5. Finally the functions which make up the program, it often improves
  872.      readability if the entry points to the program are defined first.
  873.  
  874. 
  875. File: jade.info,  Node: General Tips,  Prev: Program Layout,  Up: Tips
  876.  
  877. General Tips
  878. ------------
  879.  
  880.    The following are some general items of advice; you don't have to
  881. follow them but they are the result of experience!
  882.  
  883.    * Jade only has one name-space for all the symbols ever created,
  884.      this could lead to naming clashes if care isn't taken.
  885.  
  886.      When you write a program all the symbols it creates should be
  887.      prefixed by a name derived from the name of the program in some
  888.      way. For example, in the program `isearch.jl' all functions and
  889.      variable names are prefixed by the string `isearch-', giving
  890.      `isearch-cancel' and so on. Note that the prefix doesn't have to
  891.      be the exact name of the file, the program `buffer-menu.jl' uses
  892.      the prefix `bm-'.
  893.  
  894.      The entry points to a module (i.e. the names of the commands it
  895.      provides) should *not* have a prefix, simply give them a
  896.      descriptive name (but try not to make it too long!).
  897.  
  898.      Don't bother giving local variables these prefixes unless they are
  899.      used by several functions in the program.
  900.  
  901.    * Use the `recursive-edit' function as little as possible; it can be
  902.      *very* confusing for the user! When at all possible use keymaps to
  903.      create user interfaces.
  904.  
  905.    * Use the Lisp mode to indent your programs; not only does it save a
  906.      lot of time it also makes it easier for other people to read them.
  907.  
  908.    * Errors should always be reported by either `error' or `signal',
  909.      don't just print a message or call `beep'.
  910.  
  911.    * Don't redefine existing functions unless absolutely possible: try
  912.      to use hooks. If there is no hook where you want one, mail me
  913.      about it and I may put one in the next release.
  914.  
  915.    * Don't compile your program until you're sure it works! The
  916.      debugger only works properly with uncompiled code.
  917.  
  918.    * Use constants sparingly: personally, I only use them where the
  919.      constants are numeric.
  920.  
  921.    * Remember to define macros before they are used, otherwise they
  922.      won't be compiled inline. The same can happen if you don't
  923.      `require' a file that a macro is defined in before using the macro
  924.      definition.
  925.  
  926.    * As I said in the compilation tips (*note Compilation Tips::.), try
  927.      to use iteration instead of recursion. Also the `memq' and `assq'
  928.      types of functions can be used to search some types of list
  929.      structures very quickly.
  930.  
  931.    * When writing modes don't bind any unmodified keys to the prefix
  932.      `Ctrl-c', these are reserved for customisation by users.
  933.  
  934. 
  935. File: jade.info,  Node: Reporting Bugs,  Next: Function Index,  Prev: Programming Jade,  Up: Top
  936.  
  937. Reporting Bugs
  938. **************
  939.  
  940.    If you think you've found a bug in Jade I want to know about it,
  941. there is a list of problems that I am aware of in the `src/BUGS' file,
  942. if yours appears in there tell me anyway to make me fix it.
  943.  
  944.    When submitting bug reports I need to know as much as possible, both
  945. about the problem and the circumstances in which it occurs. In general,
  946. send me as much information as possible, even if you think it's probably
  947. irrelevant.
  948.  
  949.    If you can, contact me via email, my address is `jsh@ukc.ac.uk'.  If
  950. you don't get a reply within about a week it's probably a university
  951. vacation -- this means that I won't get your message for a while; if
  952. it's important try my postal address, this is,
  953.  
  954.      John Harper
  955.      91 Springdale Road
  956.      Broadstone
  957.      Dorset
  958.      BH18 9BW
  959.      England
  960.  
  961.    As well as bugs I'm interested in any comments you have about the
  962. editor, even if you just tell me you hate it (as long as you say *why*
  963. you hate it!).
  964.  
  965.